import { Component } from '@angular/core';
import { NavParams } from 'ionic-angular';

import { StorageService } from '../../providers/StorageService';
import { SettlementService } from '../../providers/SettlementService';

@Component({
  selector: 'page-settlementDetail',
  templateUrl: 'settlementDetail.html',
  providers: [SettlementService]
})
export class SettlementDetailPage {
  user_info: any;
  user_id: number;
  room: any;
  room_id: number;
  room_name: string;
  settlement_id: number;
  settlement: any;

  constructor(
    navParams: NavParams,
    private storageService: StorageService,
    private settlementService: SettlementService
  ) {
    this.user_info = this.storageService.read('UserInfo');
    this.user_id = this.user_info.user_id;

    this.room = this.storageService.read('RoomInfo');
    this.room_id = this.room.room_id;
    this.room_name = this.room.room_name;

    this.settlement_id = navParams.get('settlement_id');

    this.settlement = {
      'build_address' : '',
      'room_name' : '',
      'settlement_month' : '',
      'settlement_last_electricity' : '',
      'settlement_last_water' : '',
      'settlement_electricity' : '',
      'settlement_water' : '',
      'settlement_electricity_amount' : '',
      'settlement_water_amount' : '',
      'settlement_additional_amount' : '',
      'settlement_rent_amount' : '',
      'settlement_total_amount' : '',
    };

    this.settlementService.get({'user_id': this.user_id, 'room_id': this.room_id, 'settlement_id': this.settlement_id}).then(data => {
      this.settlement = data.settlement;
    });
  }
}
